<!DOCTYPE html>
<html lang="en">

	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
		<meta name="description" content="">
		<meta name="author" content="">
		<!-- STYLESHEETS -->
		<!--[if lt IE 9]><script src="../../js/flot/excanvas.min.js"></script><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]-->
		<link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css">
		<link rel="stylesheet" type="text/css" href="../../css/themes/default.css" id="skin-switcher">
		<link rel="stylesheet" type="text/css" href="../../css/responsive.css">
				<link href="../../font-awesome/css/font-awesome.min.css" rel="stylesheet">
		<!-- file-input -->
		<link rel="stylesheet" type="text/css" href="../../js/file-input/fileinput.css" />
		<!-- datatable -->
		<link rel="stylesheet" href="../../js/datatables/datatable.css">
		<!-- WIZARD -->
		<link rel="stylesheet" type="text/css" href="../../js/bootstrap-wizard/wizard.css" />
		<!-- SELECT2 -->
		<link rel="stylesheet" type="text/css" href="../../js/select2/select2.min.css" />

	</head>

	<body>
		<header class="navbar clearfix" id="header">
		</header>

		<!-- PAGE -->
		<section id="page">
			<!-- SIDEBAR -->
			<div id="sidebar" class="sidebar">
			<div class="sidebar-menu nav-collapse">
						
						<!-- SIDEBAR MENU -->
						<ul>							
							
							
						</ul>
						<!-- /SIDEBAR MENU -->
					</div>

			</div>
			<!-- /SIDEBAR -->
			<div id="main-content">
			
				<div class="container">
					<div class="row">
						<div id="content" class="col-lg-12">
							<!-- PAGE HEADER-->
							<div class="row">
								<div class="col-sm-12">
									<div class="page-header">
										<!-- STYLER -->

										<!-- /STYLER -->
										<!-- BREADCRUMBS -->
										<ul class="breadcrumb">
											<li>
												<i class="fa fa-home"></i>
												<a href="index.html">首页</a>
											</li>
											<li>
												<a href="#">订单管理</a>
											</li>
											<li>订单详情</li>
										</ul>
										<!-- /BREADCRUMBS -->

									</div>
								</div>
							</div>
							<!-- /PAGE HEADER -->
							<!-- SAMPLE -->

							<div class="row">
								<div class="col-md-12" style="background-color:#ffffff">
									<div class="box" style="margin-top:10px">
										<div class="box-title" style="border-bottom:1px solid #5e87b0;line-height:38px">
											<h4><i class="fa fa-file" style="color:red"></i>基本信息</h4>
											<a class="btn btn-default" href="return_order_list.html" style="float:right">返回订单列表</a>
										</div>
										<div class="box-body">
											<div class="form-group  mrg-bt10">
											   <label class="control-label col-md-2 " style="width:110px">申请单编号：</label>
												<div class="col-md-2 inline" id="returnCode" style="width:110px">
												</div>
												<label class="control-label col-md-2 " style="width:100px">订单编号：</label>
												<div class="col-md-2 inline" id="orderId" style="width:110px">
												</div>
												<label class="control-label col-md-2 " style="width:70px">类型：</label>
												<div class="col-md-2 inline" id="returnType" style="width:70px">
												</div>
												<label class="control-label col-md-2 " style="width:70px">状态：</label>
												<div class="col-md-2 inline" id="returnStatus" style="width:110px">
												</div>
												<label class="control-label col-md-2 " style="width:100px">申请时间：</label>
												<div class="col-md-2 inline" id="createTime">
												</div>												
											</div>
											<div class="form-group  mrg-bt10">
											    <label class="control-label col-md-2 " style="width:100px">收货电话：</label>
												<div class="col-md-2 inline" id="orderTelPhone">
												</div>
											</div>
											
										</div>
									</div>
									<div class="box div_change" style="display:none">
										<div class="box-title" style="border-bottom:1px solid #5e87b0">
											<h4><i class="fa fa-user" style="color:#eea236"></i>收货信息</h4>
										</div>
										<div class="box-body">
											<div class="form-group mrg-bt10">
												<label class="control-label col-md-2" style="width:100px">收货人：</label>
												<div class="col-md-2 inline" id="receiver">
												</div>
												<label class="control-label col-md-2" style="width:100px">电话：</label>
												<div class="col-md-2 inline" id="telPhone">
												</div>
												<label class="control-label col-md-2" style="width:100px">地址：</label>
												<div class="col-md-3 inline" id="address">
												</div>
											</div>
											
										</div>
									</div>
									<div class="box div_sourceproduct">
										<div class="box-title" style="border-bottom:1px solid #5e87b0">
											<h4><i class="fa fa-archive" style="color:#468847"></i>原商品信息</h4>
										</div>
										<div class="box-body">
											<div class="form-group" style="height:auto;">
												<table id="source_sku_list" class="table table-bordered">
													<thead>
													<tr>
														<th>商品名称</th>
														<th>SKU编码</th>
														<th>颜色/规格</th>
														<th>尺码</th>														
														<th>明细状态</th>
														<th>退款状态</th>
																				
														</tr>
													</thead>
													<tbody>														
													</tbody>
												</table>
											</div>
										</div>
									</div>
									<div class="box div_product">
										<div class="box-title" style="border-bottom:1px solid #5e87b0">
											<h4><i class="fa fa-archive" style="color:#468847"></i>退换商品信息</h4>
										</div>
										<div class="box-body">
											<div class="form-group" style="height:auto;">
												<table id="sku_list" class="table table-bordered">
													<thead>
													<tr class='sl-head'>
														<th>商品名称</th>
														<th>SKU编码</th>
														<th>颜色/规格</th>
														<th>尺码</th>													
														<th>数量</th>
														<th class='sds' style="display: none">明细状态</th>
														<th class='srs' style="display: none">退款状态</th>
													
														
																				
													</tr>
													</thead>
													<tbody>														
													</tbody>
												</table>
											</div>
										</div>
									</div>
									
									<div class="box div_change" style="display:none">
										<div class="box-title" style="border-bottom:1px solid #5e87b0">
											<h4><i class="fa fa-truck" style="color:#d9edf7"></i>物流信息</h4>
										</div>
										<div class="box-body">
										 <div class="form-group  mrg-bt10">
										 <label class="control-label col-md-2" style="width:150px">用户寄出物流公司：</label>
												<div class="col-md-2 inline" id="userExpressCompany">
												</div>
												 <label class="control-label col-md-2" style="width:150px">用户寄出物流单号：</label>
												<div class="col-md-2 inline" id="userExpressCode">
												</div>
										 </div>
											<div class="form-group  mrg-bt10 logisticsList">
												<label class="control-label col-md-2" style="width:100px">物流公司：</label>
												<div class="col-md-2 inline" id="expressCompany">
												</div>
												<label class="control-label col-md-2" style="width:100px">物流单号：</label>
												<div class="col-md-2 inline" id="expressCode">
												</div>
												
											</div>
										</div>
									</div>
									<div class="box div_returnlog">
										<div class="box-title" style="border-bottom:1px solid #5e87b0">
											<h4><i class="fa fa-smile-o" style="color:#fcd76a"></i>进度跟踪</h4>
										</div>
										<div class="box-body">
											<table id="log_list" class="table table-bordered">
													<thead>
													<tr>
														<th style="width:15%">操作时间</th>
														<th style="width:55%">描述</th>
														<th style="width:20%">备注</th>
														<th style="width:10%">操作人</th>
																											
														</tr>
													</thead>
													<tbody>														
													</tbody>
												</table>
										</div>
									</div>
								</div>
							</div>

							<!-- /SAMPLE -->

							<div class="footer-tools">
								<span class="go-top">
								<i class="fa fa-chevron-up"></i> Top
							</span>
							</div>
						</div>
						<!-- /CONTENT-->
					</div>
				</div>
			</div>
		</section>
		<!--/PAGE -->
		<!-- JAVASCRIPTS -->
		<!-- Placed at the end of the document so the pages load faster -->
		<!-- JQUERY -->
		<script src="../../js/jquery/jquery-2.0.3.min.js"></script>

		<!-- BOOTSTRAP -->
		<script src="../../bootstrap-dist/js/bootstrap.min.js"></script>
			<!--bootbox-->
		<script type="text/javascript" src="../../js/bootbox/bootbox.min.js"></script>
		<!-- COOKIE -->
		<script type="text/javascript" src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>
		<!-- SELECT2 -->
		<script type="text/javascript" src="../../js/select2/select2.min.js"></script>
		<!-- CUSTOM SCRIPT -->
		<script src="../../js/script.js"></script>
		<script src="../../js/common.js"></script>

		<script>
			var AddDetail = function() {
				var id,userId,orderStatus,oId,wdtCode,telPhone,returnType,returnStatus;
				var allSend=true;
			    var getStatusDesc=function(returOrderStatus){
			       var str="";
								   switch(returOrderStatus){
								     case "WaitingReturnGoods":str="待退货";break;
								     case "WaitingReturnMoney":str="待退款";break;
								     case "WaitingInStock":str="待入库";break;
								     case "WaitingCheck":str="待审核";break;
								     case "WaitingSend":str="待发货";break;
								     case "WaitingSign":str="待签收";break;
								     case "Complete":str="已完成";break;
								     case "Reject":str="审批未通过";break;
								     case "Cancel":str="已取消";break;
								   }
								   return str;
				};
				
				var getDetail = function(returnCode,userId,oId) {
					$.ajax({
						type: "get",
						url: App.getContextPath() + "agent/returnorder/returnorderDetail.do",
						data: {
							returnCode: returnCode,userId:userId
						},
						async: true,
						success: function(result) {
						if(result!=null){
							returnStatus = result.returnStatus;
							returnType = result.returnType;
							//判断退货类型
							if(result.returnType=="Return"){//退货
								$(".div_return").show();
								$("#returnType").html("退货");
								$(".div_sourceproduct").hide();
								
							}else{//换货
								$(".div_change").show();
								$("#returnType").html("换货");
								$(".div_sourceproduct").show();
								if(result.returnStatus=="WaitingCheck"||result.returnStatus=="WaitingReturnGoods"){
									$(".div_change").hide();
								}
								 $.each(result.sourceDetailList,function(index,item){
								     var tr="<tr><td>"+item.productName+"</td><td>"+item.sourceSkuCode+"</td><td>"+item.shortName+"</td><td>"+item.sourceSizeName+"</td><td>"+ item.orderDetailStatusStr+"</td><td>"+ item.refundStatusStr+"</td></tr>";
								     $("#source_sku_list tbody").append(tr);
								   });
							}
							if(result.returnStatus=="Reject"){
								$(".div_change").hide();
							}							
						   $("#returnCode").html(returnCode);
						   $("#orderId").html(result.orderId);
						   $("#returnStatus").html(getStatusDesc(result.returnStatus));
						   
						   $("#createTime").html($.getLocalTime(result.createTime));
						   $("#receiver").html(result.receiver);
						   $("#telPhone").html(result.telPhone);
						   $("#address").html(result.provinceName+result.cityName+result.areaName+result.address);
						   $("#sendTime").html(result.sendTime==null?"":$.getLocalTime(result.sendTime));
						   $(".returnReason").html(result.returnReason);
						   $("#orderPayCode").html(result.orderPayCode);
						 
						   if(result.returnStatus=="Complete"){
						  	 $("#refundTime").html($.getLocalTime(result.updateTime));
						   }
						   $("#updateBy").html(result.updateBy);
						   
						   $("#userExpressCompany").html(result.userExpressCompany);
						   $("#userExpressCode").html(result.userExpressCode);
						   if(result.returnStatus!="WaitingCheck")
							   $(".div_yijian").hide();
						   //显示图片
						   var str="";
						   $.each(result.returnImgPath.split(','),function(index,item){
							   
							   str+="<img src='"+item+"' style='height:150px' >";
							});
						   $(".returnImgPath").html(str);
						   $.each(result.returnType=="Return"?result.sourceDetailList:result.detailList,function(index,item){
							   if(item.orderDetailStatus !='WaitingSign'){
								   allSend = false;
							   }
							
							 var tr="<tr><td>"+item.productName+"</td><td>"+item.skuCode+"</td><td>"+item.shortName+"</td><td>"+item.sizeName+"</td><td>"+item.amount+"</td>"
						   	if(returnType=='Return'){
						   	  $("#sku_list thead").find(".sds").show();
						   	  $("#sku_list thead").find(".srs").show();
						   		tr+= "<td>"+ item.orderDetailStatusStr+"</td><td>"+ item.refundStatusStr+"</td>";
						   	}
						   	if(returnStatus !='Cancel' && returnStatus !='Reject'&&returnStatus !='WaitingCheck'&&returnStatus !='WaitingReturnGoods'){
						   	  $("#sku_list thead").find(".wis").show();
						   	
						   	}
						   	
						     
						     tr+= "</tr>"
						     $("#sku_list tbody").append(tr);
						   
						   });
						  
						   //循环物流
						   var str="";
						   if(result.logisticsList!=null){
							   $.each(result.logisticsList,function(index,m){
								   str+='<div class="form-group  mrg-bt10 "><label class="control-label col-md-2" style="width:150px">物流公司：</label>'+
									    '<div class="col-md-2 inline" >'+m.expressCompany+
									    '</div>'+
									    '<label class="control-label col-md-2" style="width:100px">物流单号：</label>'+
									'<div class="col-md-2 inline" >'+m.expressCode+
									'</div></div>';
									
							   });
							   $(".logisticsList").empty().append(str);
						   }else{
							   $(".logisticsList").parent().hide();
						   }
						}
						}
					});
				};
				
				
				
				var getReturnLogs=function(id){
					$.ajax({
						type: "get",
						url: App.getContextPath() + "agent/returnorder/getReturnLogs.do",
						data: {returnCode:id},
						async: true,
						success: function(result) {
							var str="";
							$.each(result,function(index,item){
								if(item.remark ==null){
									item.remark ="";
								}
									
								str+='<tr><td>'+$.getLocalTime(item.createTime)+'</td>   <td>'+item.operation+'</td> <td>'+item.remark+'</td> <td>'+item.createBy+'</td></tr>';
							});
							$("#log_list tbody").empty().append(str);
						}
					});
				}
				return {
					init: function() {
						App.init();
						id=$.getUrlParam("id");	
						userId=$.getUrlParam("userId");
						orderStatus=$.getUrlParam("orderStatus");
						oId=$.getUrlParam("oId");												
						getDetail(id,userId,oId);
						getReturnLogs(id);					
						$("#orderTelPhone").html($.getUrlParam("telPhone"));
					}
				}
			}();
			$(function() {
				$("#header").load("../head.html");
				///$("#sidebar").load("../menu.html");
				AddDetail.init();
			});
		</script>

		<!-- /JAVASCRIPTS -->
	</body>

</html>